package org.hfy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 合同状态枚举
 * 
 * @author hfy
 * @version 1.0
 */
@Getter
@AllArgsConstructor
public enum ContractStatusEnum {
    
    PENDING_AUDIT("PENDING_AUDIT", "待审核"),
    AUDIT_PASSED("AUDIT_PASSED", "审核通过"),
    AUDIT_REJECTED("AUDIT_REJECTED", "审核拒绝");
    
    private final String code;
    private final String description;
    
    /**
     * 根据代码获取枚举
     */
    public static ContractStatusEnum fromCode(String code) {
        for (ContractStatusEnum status : ContractStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的合同状态代码: " + code);
    }
    
    /**
     * 根据描述获取枚举
     */
    public static ContractStatusEnum fromDescription(String description) {
        for (ContractStatusEnum status : ContractStatusEnum.values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的合同状态描述: " + description);
    }
} 